package com.example.routeplansystem.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger2配置文件
 */

@Configuration
@EnableSwagger2
public class Swagger2Config {

    @Bean
    public Docket getDocket(){

        //创建封面信息：
        ApiInfoBuilder apiInfoBuilder = new ApiInfoBuilder();
        apiInfoBuilder.title("【路径规划系统】后端接口文档")
                .description("此文档详细的描述了路径规划项目后端接口规范......")
                .version("v 2.0.0 重构版本")
                .contact(new Contact("krian","https://blog.csdn.net/weixin_52058417?spm=1019.2139.3001.5343","2793260947@qq.com"));

        ApiInfo apiInfo = apiInfoBuilder.build();

        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.routeplansystem.controller")) //配置包路径！！！
                .paths(PathSelectors.any())
                .build();
    }
}
